package com.jvxb.manage.configuration.websocket;

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

/**
 * 开启WebSocket支持
 */
@Configuration
public class WebSocketConfig {

    /**
     * 开发环境使用内嵌tomcat，需要自行注入ServerEndpointExporter，
     * 其他环境使用外置tomcat，无需注入ServerEndpointExporter
     */
    @Bean
    @ConditionalOnExpression("'${env}'.equals('dev')")
    public ServerEndpointExporter serverEndpointExporter() {
        return new ServerEndpointExporter();
    }
}